package jdk8.homework.Demo08;

import java.util.ArrayList;
import java.util.function.Predicate;

public class Demo08 {
    static ArrayList<String> arrayList = new ArrayList<>();

    public static void main(String[] args) {
        String[] array = {"迪丽热巴,女", "古力娜扎,女", "马尔扎哈,男", "赵丽颖,女"};
        for (String s : array) {
            set((s1) -> {
                return s.split(",")[0].length() == 4;
            }, (s1) -> {
                return s.split(",")[1].equals("女");
            }, s);
        }

        System.out.println(arrayList);
    }

    private static void set(Predicate<String> predicate1, Predicate<String> predicate2, String s) {
        if (predicate1.and(predicate2).test(s)) {
            arrayList.add(s);
        }
    }
}
